interface PageQueryEntity {
    limit?: string
    offset?: string
    [key: string]: any
}



class PageQuery implements PageQueryEntity {
    limit?: string
    offset?: string
    [key: string]: any
    constructor(param: {[key: string]: string}){
        this.limit = param['limit'];
        this.offset = param['offset'];
        for(let k in param){
            if(k != 'offset' && k != 'limit'){
                this[k] = param[k];
            }
        }
    }
    getLimit(): number{
        return parseInt(this.limit == null ? '1' : this.limit);
    }
    getOffset(): number {
        return this.offset == '0' ? 0 
             : this.offset == '1' ? 0 
             : ( parseInt(this.offset == null ? '1' : this.offset) - 1 ) * this.getLimit();
    }
}

export { PageQuery , type PageQueryEntity}